import { type Component, markRaw } from 'vue'
import { v4 as uuidv4 } from 'uuid'
import SuggestQuestion from '../modules/SuggestQuestion.vue'
import SeriveScore from '../modules/ServiceScore.vue'
import FeedbackPanel from '../modules/FeedbackPanel.vue'

type User = {
  name: string
  avatar: string
}

export type Message = {
  id: number | string
  type: 'user' | 'robot'
  msg: {
    text: string
    imgUrl?: string
  }
  compontent?: Array<Component>
}

export const robot: User = {
  name: '张国涛',
  avatar: 'https://img2.baidu.com/it/u=2814429148,2262424695&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1729875600&t=dbb775cc03789fef60b9d06d52face4c'
}

export const user: User = {
  name: '',
  avatar: 'https://avatars.githubusercontent.com/u/42566669?v=4'
}

export const suggestQuestion = markRaw(SuggestQuestion)
export const seriveScore = markRaw(SeriveScore)
export const feedbackPanel = markRaw(FeedbackPanel)

export const mockMessageList: Array<Message> = [
  {
    id: uuidv4(),
    type: 'robot',
    msg: {
      text: "您好，我是您的医生助手。"
    },
    compontent: [suggestQuestion]
  },
    {
    id: uuidv4(),
    type: 'robot',
    msg: {
      text: "请在下方输入框详细描述病情，以便医生准确了解您的情况，快速接诊"
    },
    compontent: [suggestQuestion]
  }
]

export const rotbotReply = (item: string): Message => {
  switch (item) {
    case '头疼嗓子不舒服':
      return {
        id: uuidv4(),
        type: 'robot',
        msg: {
          text: '请稍等，正在为您匹配相应医生'
        }
      }
    case '医生我最近嗓子不舒服':
      return {
        id: uuidv4(),
        type: 'robot',
        msg: {
          text: '可能是感冒的了，这边建议您多喝水，多休息,提前准备好感冒药',

        }
      }
    case '好的谢谢您':
      return {
        id: uuidv4(),
        type: 'robot',
        msg: {
          text: '不用谢，祝您早日康复'
        },
        compontent: [feedbackPanel]
      }
    case '订单没有成功，如何解决?':
      return {
        id: uuidv4(),
        type: 'robot',
        msg: {
          text: '您可以检查网络是否通畅，看是否成功下单呢？'
        }
      }
    case '人工客服':
      return {
        id: uuidv4(),
        type: 'robot',
        msg: {
          text: '当前人工客服忙，结束当前会话！'
        },
        compontent: [seriveScore]
      }
    default:
      return {
        id: uuidv4(),
        type: 'robot',
        msg: {
          text: '不明白您的意思～请您重新提问'
        }
      }
  }
}
